<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">

</style>
<script type="text/javascript" src="/js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="/js/jquery-ui-1.8.21.custom.min.js"></script>
<script type="text/javascript" src="/js/jquery.leanModal.min.js"></script>
<link type="text/css" href="/css/start/jquery-ui-1.8.21.custom.css" rel="Stylesheet" />	

<script language="javascript"> 
$(function() {
	$( "#date_begin" ).datepicker({ dateFormat: "yy-mm-dd",firstDay: 1 });
	$( "#date_end" ).datepicker({ dateFormat: "yy-mm-dd",firstDay: 1 });
});	
</script>
    

</head>

<body  style="font-family:Arial, Helvetica, sans-serif" >
<h2>Alex Order List</h2>
<form method = "post" action = "">
Date Start:<input type = "text" name = "date_begin" id = "date_begin"></input>
Date End:<input type = "text" name = "date_end" id = "date_end"></input>
<input type = "submit" name = "submit" id = "submit" value = "submit"></input><br/><br/>
<?php $rProduct = new Model_DbTable_Pr_Prproducts();
	  $shopList = unserialize(ARR_RCENTER_REV_MAPPING);
	  $staffDetail = new Model_DbTable_Roster_Stafflogindetail();
	  $rJob = new Model_DbTable_Repairjob();
?>
<h3>Alex Order Parts List</h3>
	<table width="500" border="1" cellspacing="1" cellpadding="5">
		<tr>
			<th>Barcode</th>
			<th>Title</th>
			<th>Qty</th>
			<th>Cost(IC GST)</th>
			<th>Total Cost(IC GST)</th>
			<th>Date Order</th>
		</tr>
		<?php if ($this->orderList){
			$total = 0;
		?>
		<?php foreach($this->orderList as $k => $v){
			$partsTCost = 0;
			$rDetail = $rProduct->getProduct($v['id_product']);
		?>
		<?php if($rDetail['price_t']){?>
		<tr>
			
			<td><?php echo $rDetail['code_product']?><?php echo ($rDetail['active'])?'':'[X]';?></td>
			<td><?php echo $rDetail['title_product']?></td>
			<td><?php echo $v['qty_product']?></td>
			<td><?php $costParts = $rDetail['price_t']*1.1;
					  $partsTCost = $costParts*$v['qty_product'];
					  $total += $costParts*$v['qty_product'];
					  if($rDetail['price_t'] == 0){
							echo "<span style = \"color:red\">" + $costParts + "</span>";	
					  }else{
							echo $costParts;
					  }
					?></td>
			<td><?php echo $partsTCost;?></td>		
			<td><?php echo $v['date_move']?></td>
			
		</tr>
		<?php }?>
		<?php }?>
		<?php foreach($this->orderList as $k => $v){
			$partsTCost = 0;
			$rDetail = $rProduct->getProduct($v['id_product']);
		?>
		<?php if(!$rDetail['price_t']){?>
		<tr>	
			<td><?php echo $rDetail['code_product']?></td>
			<td><?php echo $rDetail['title_product']?></td>
			<td><?php echo $v['qty_product']?></td>
			<td><?php echo "<span style = \"color:red\">Null Cost</span>";?></td>
			<td><?php echo $partsTCost;?></td>		
			<td><?php echo $v['date_move']?></td>
		</tr>
		<?php }?>
		<?php }?>

		<tr>
			<td colspan = "6">Total Cost:$<?php echo $total?></td>
		</tr>
		<?php }?>
	</table>
	<h3>Alex Borrow In List</h3>
	<table width="900" border="1" cellspacing="1" cellpadding="5">
		<tr>
			<th>Barcode</th>
			<th>Title</th>
			<th>Qty</th>
			<th>Cost(IC GST)</th>
			<th>Total Cost(IC GST)</th>
			<th>Borrow In Date</th>
			<th>Job Id</th>
			<th>Borrow From</th>
			<th>Apply Staff</th>
			<th>Confirm Staff</th>
		</tr>
		<?php if ($this->alexIn){
			$total2 = 0;
		?>
		<?php foreach($this->alexIn as $k2 => $v2){
			$partsTCost2 = 0;
			$rDetail = $rProduct->getProduct($v2['id_product']);
			$appstaffNi = $staffDetail->getDetail($v2['id_staff']);
			$confstaffNi = $staffDetail->getDetail($v2['id_staff_confirm']);
		?>
		<?php if($rDetail['price_t']){?>
		<tr>
			
			<td><?php echo $rDetail['code_product']?><?php echo ($rDetail['active'])?'':'[X]';?></td>
			<td><?php echo $rDetail['title_product']?></td>
			<td><?php echo $v2['qty_product']?></td>
			<td><?php $costParts2 = $rDetail['price_t']*1.1;
					  $partsTCost2 = $costParts2*$v2['qty_product'];
					  $total2 += $costParts2*$v2['qty_product'];
					  if($rDetail['price_t'] == 0){
							echo "<span style = \"color:red\">" + $costParts2 + "</span>";	
					  }else{
							echo $costParts2;
					  }
					?></td>
			<td><?php echo $partsTCost2;?></td>		
			<td><?php echo $v2['date_loan']?></td>
			<td><?php echo $v2['id_job']?></td>
			<td><?php echo $shopList[$v2['shop_from']]?></td>
			<td><?php echo $appstaffNi['ni']?></td>
			<td><?php echo $confstaffNi['ni']?></td>
			
		</tr>
		<?php }?>
		<?php }?>
		<?php foreach($this->alexIn as $k => $v2){
			$partsTCost2 = 0;
			$rDetail = $rProduct->getProduct($v2['id_product']);
			$appstaffNi = $staffDetail->getDetail($v2['id_staff']);
			$confstaffNi = $staffDetail->getDetail($v2['id_staff_confirm']);
		?>
		<?php if(!$rDetail['price_t']){?>
		<tr>	
			<td><?php echo $rDetail['code_product']?></td>
			<td><?php echo $rDetail['title_product']?></td>
			<td><?php echo $v2['qty_product']?></td>
			<td><?php echo "<span style = \"color:red\">Null Cost</span>";?></td>
			<td><?php echo $partsTCost;?></td>		
			<td><?php echo $v2['date_loan']?></td>
			<td><?php echo $v2['id_job']?></td>
			<td><?php echo $shopList[$v2['shop_from']]?></td>
			<td><?php echo $appstaffNi['ni']?></td>
			<td><?php echo $confstaffNi['ni']?></td>
		</tr>
		<?php }?>
		<?php }?>

		<tr>
			<td colspan = "10">Total Cost:$<?php echo $total2?></td>
		</tr>
		<?php }?>
	</table>	
	<h3>Alex Borrow Out List( Not Repair by alex )</h3>
	<table width="900" border="1" cellspacing="1" cellpadding="5">
		<tr>
			<th>Barcode</th>
			<th>Title</th>
			<th>Qty</th>
			<th>Cost(IC GST)</th>
			<th>Total Cost(IC GST)</th>
			<th>Borrow Out Date</th>
			<th>Job Id</th>
			<th>Borrow to Shop</th>
			<th>Apply Staff</th>
			<th>Confirm Staff</th>
			<th>Fix By</th>
		</tr>
		<?php if ($this->alexOut){
			$total2 = 0;
		?>
		<?php foreach($this->alexOut as $k2 => $v2){
			$partsTCost2 = 0;
			$rDetail = $rProduct->getProduct($v2['id_product']);
			$appstaffNi = $staffDetail->getDetail($v2['id_staff']);
			$confstaffNi = $staffDetail->getDetail($v2['id_staff_confirm']);
			$jobDetail = $rJob->getJob($v2['id_job']);
			$staff = $staffDetail->getDetail($jobDetail['repair_staff']);
		?>
		<?php if($rDetail['price_t']){?>
		<tr>
			
			<td><?php echo $rDetail['code_product']?><?php echo ($rDetail['active'])?'':'[X]';?></td>
			<td><?php echo $rDetail['title_product']?></td>
			<td><?php echo $v2['qty_product']?></td>
			<td><?php $costParts2 = $rDetail['price_t']*1.1;
					  $partsTCost2 = $costParts2*$v2['qty_product'];
					  $total2 += $costParts2*$v2['qty_product'];
					  if($rDetail['price_t'] == 0){
							echo "<span style = \"color:red\">" + $costParts2 + "</span>";	
					  }else{
							echo $costParts2;
					  }
					?></td>
			<td><?php echo $partsTCost2;?></td>		
			<td><?php echo $v2['date_loan']?></td>
			<td><?php echo $v2['id_job']?></td>
			<td><?php echo $shopList[$v2['shop_to']]?></td>
			<td><?php echo $appstaffNi['ni']?></td>
			<td><?php echo $confstaffNi['ni']?></td>
			<td><?php echo $staff['ni']?></td>
			
		</tr>
		<?php }?>
		<?php }?>
		<?php foreach($this->alexIn as $k => $v2){
			$partsTCost2 = 0;
			$rDetail = $rProduct->getProduct($v2['id_product']);
			$appstaffNi = $staffDetail->getDetail($v2['id_staff']);
			$confstaffNi = $staffDetail->getDetail($v2['id_staff_confirm']);
			$jobDetail = $rJob->getJob($v2['id_job']);
			$staff = $staffDetail->getDetail($jobDetail['repair_staff']);
		?>
		<?php if(!$rDetail['price_t']){?>
		<tr>	
			<td><?php echo $rDetail['code_product']?></td>
			<td><?php echo $rDetail['title_product']?></td>
			<td><?php echo $v2['qty_product']?></td>
			<td><?php echo "<span style = \"color:red\">Null Cost</span>";?></td>
			<td><?php echo $partsTCost;?></td>		
			<td><?php echo $v2['date_loan']?></td>
			<td><?php echo $v2['id_job']?></td>
			<td><?php echo $shopList[$v2['shop_to']]?></td>
			<td><?php echo $appstaffNi['ni']?></td>
			<td><?php echo $confstaffNi['ni']?></td>
			<td><?php echo $staff['ni']?></td>
		</tr>
		<?php }?>
		<?php }?>

		<tr>
			<td colspan = "11">Total Cost:$<?php echo $total2?></td>
		</tr>
		<?php }?>
	</table>
	
	
</form>

</body>
</html>
